package cn.itcast.bos.utils;

public class HtmlWordsToStringUtils {
	/**
	 * 对特殊的html字符进行编码
	 * 
	 * @param message
	 * @return
	 */
	public static String filter(String message) {

		if (message == null || message.length() == 0)
			return (null);
		StringBuilder result = new StringBuilder();
		for (int i = 0; i < message.length(); i++) {
			switch (message.charAt(i)) {
			case '<':
				result.append("&lt;");
				break;
			case '>':
				result.append("&gt;");
				break;
			case '&':
				result.append("&amp;");
				break;
			case '"':
				result.append("&quot;");
				break;
			default:
				result.append(message.charAt(i));
			}
		}
		return (result.toString());

	}

}